package com.member.web.controller.shop;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.member.common.annotation.Log;
import com.member.common.core.controller.BaseController;
import com.member.common.core.domain.AjaxResult;
import com.member.common.core.page.TableDataInfo;
import com.member.common.enums.BusinessType;
import com.member.common.utils.poi.ExcelUtil;
import com.member.shop.domain.SysBizGoodsRankCategory;
import com.member.shop.service.ISysBizGoodsRankCategoryService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 【排行榜单分类】控制器
 *
 * @author lixinchen
 * @version 1.0
 * @date 2025-01-13
 **/
@RestController
@RequestMapping("/shop/goodsRankCategory")
public class SysBizGoodsRankCategoryController extends BaseController {
    @Resource
    private ISysBizGoodsRankCategoryService sysBizGoodsRankCategoryService;

    /**
     * 查询排行榜单分类列表
     */
    @PreAuthorize("@ss.hasPermi('shop:goodsRankCategory:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysBizGoodsRankCategory sysBizGoodsRankCategory) {
        startPage();
        List<SysBizGoodsRankCategory> list = sysBizGoodsRankCategoryService.selectSysBizGoodsRankCategoryList(sysBizGoodsRankCategory);
        return getDataTable(list);
    }

    /**
     * 导出排行榜单分类列表
     */
    @PreAuthorize("@ss.hasPermi('shop:goodsRankCategory:export')")
    @Log(title = "排行榜单分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysBizGoodsRankCategory sysBizGoodsRankCategory) {
        List<SysBizGoodsRankCategory> list = sysBizGoodsRankCategoryService.selectSysBizGoodsRankCategoryList(sysBizGoodsRankCategory);
        ExcelUtil<SysBizGoodsRankCategory> util = new ExcelUtil<SysBizGoodsRankCategory>(SysBizGoodsRankCategory. class);
        util.exportExcel(response, list, "排行榜单分类数据");
    }

    /**
     * 获取排行榜单分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('shop:goodsRankCategory:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(sysBizGoodsRankCategoryService.selectSysBizGoodsRankCategoryById(id));
    }

    /**
     * 新增排行榜单分类
     */
    @PreAuthorize("@ss.hasPermi('shop:goodsRankCategory:add')")
    @Log(title = "排行榜单分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysBizGoodsRankCategory sysBizGoodsRankCategory) {
        return toAjax(sysBizGoodsRankCategoryService.insertSysBizGoodsRankCategory(sysBizGoodsRankCategory));
    }

    /**
     * 修改排行榜单分类
     */
    @PreAuthorize("@ss.hasPermi('shop:goodsRankCategory:edit')")
    @Log(title = "排行榜单分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysBizGoodsRankCategory sysBizGoodsRankCategory) {
        return toAjax(sysBizGoodsRankCategoryService.updateSysBizGoodsRankCategory(sysBizGoodsRankCategory));
    }

    /**
     * 删除排行榜单分类
     */
    @PreAuthorize("@ss.hasPermi('shop:goodsRankCategory:remove')")
    @Log(title = "排行榜单分类", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sysBizGoodsRankCategoryService.deleteSysBizGoodsRankCategoryByIds(ids));
    }
}
